package com.example.baselib.utils.log;

/**
 * Description:  TODO
 * Author: admin
 * CreateDate: 2021/4/2 8:56
 */
public class LogManager {

    private ILog mILog;
    private LogConfig.ConfigBuilder mConfigBuilder;
    private static LogManager manager;

    private LogManager() {
        mConfigBuilder = new LogConfig.ConfigBuilder();
        createDefLogImpl(mConfigBuilder.build());
    }

    private void createDefLogImpl(LogConfig logConfig) {
        mILog = new LogImpl(logConfig);
    }

    public static LogManager getInstance() {
        if (manager == null) {
            synchronized (LogManager.class) {
                if (manager == null) {
                    manager = new LogManager();
                }
            }
        }
        return manager;
    }

    public void setTag(String tag) {
        mConfigBuilder.setTag(tag);
        createDefLogImpl(mConfigBuilder.build());
    }

    public void setDomain(int domain) {
        mConfigBuilder.setDomain(domain);
        createDefLogImpl(mConfigBuilder.build());
    }

    public void setPrivate(boolean isPrivate) {
        mConfigBuilder.setPrivate(isPrivate);
        createDefLogImpl(mConfigBuilder.build());
    }

    public void setShowLineNum(boolean isShow) {
        mConfigBuilder.setShowLineNum(isShow);
        createDefLogImpl(mConfigBuilder.build());
    }

    public void setLogLevel(LogLevel level) {
        mConfigBuilder.setLogLevel(level);
        createDefLogImpl(mConfigBuilder.build());
    }

    public ILog getILogImpl() {
        return mILog;
    }


}
